package me.yingjie.common.components

import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.delay
import java.time.LocalTime
import java.time.format.DateTimeFormatter

@Composable
fun Clock() {
    val currentTime = remember { mutableStateOf(LocalTime.now()) }
    LaunchedEffect(Unit) {
        while (true) {
            delay(1000) // 每秒刷新一次
            currentTime.value = LocalTime.now()
        }
    }
    Text(currentTime.value.format(DateTimeFormatter.ofPattern("HH:mm:ss")),
        fontSize = 25.sp, textAlign = TextAlign.Center)
}

@Composable
fun LeftSide(){
   Clock()
}